# 递归目录使用网络api反编译目录下的所有pyc文件
import walk_pyc
import decom_api
import os
import time

from sys import argv

if __name__ =='__main__':
    if len(argv) < 2:
        print('Usage: python ./main.py dirname')
    else:
        dirname = argv[1]
        if os.path.isdir(dirname):
            pyc_list = walk_pyc.walk_pyc(dirname)
            len = len(pyc_list)
            print('Find {} Pyc File'.format(len))
            print('Start Decomplie Pyc Files')
            for file in pyc_list:
                decom_api.decomplie(file)
                print('Decompile {} Finish'.format(file))
                time.sleep(2)
        else:
            print('Please Input A Dirname')
            print('Usage: python ./main.py dirname')